package ts.test.factory;

import ts.test.dao.NewsDao;
import ts.test.dao.impl.NewsDaoMysqlImpl;
import ts.test.dao.impl.NewsDaoOracleImpl;
import ts.test.dao.impl.NewsDaoRedisImpl;

public class SimpleDaoFactory {
    /**
     * 创建NewsDao实列工厂
     */
    public static NewsDao getInstance(String key){
//        return new NewsDaoImpl();
        switch (key){
            case "mysql":
                return new NewsDaoMysqlImpl();
            case "oracle":
                return new NewsDaoOracleImpl();
            case "redis":
                return new NewsDaoRedisImpl();
            //default:
                //return new RuntimeException("无效的数据库类型："+ key + ",DAO获取失败");
            default:
                return null;
        }
    }
}
